package tp.badugi.client.guiViews;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import tp.badugi.client.GuiClient;

public class ConnectionView extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1224617553012253077L;

	private GuiClient client;
	
	private final Dimension conncetionViewSize = new Dimension(300, 200);
	
	public JTextField connectionServerIpAddressField = new JTextField("IP Address");
	public JTextField connectionServerPortNumber = new JTextField("Port");
	
	public JButton connectionConnectToServerButton = new JButton("Connect");
	
	private JLabel validationMessager = new JLabel(); 
	
	public ConnectionView(GuiClient client) {
		this.client = client;
		
		this.makeView();
	}
	
	private void makeView(){
		this.setTitle(this.client.title);
		
		this.setBounds(new java.awt.Rectangle(this.client.windowBoundPoint, this.conncetionViewSize));
		
		this.setFont(this.client.clientFont);
		this.setLayout(new GridLayout(4, 1));
		
		this.connectionServerIpAddressField.setFont(this.client.clientFont);
		
		this.add(this.connectionServerIpAddressField);
		this.add(this.connectionServerPortNumber);
		this.add(this.connectionConnectToServerButton);
		this.add(this.validationMessager);
		
		this.connectionConnectToServerButton.addActionListener(this.client);
		
		this.setVisible(true);
		this.setResizable(false);
		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
